package cn.bdqn.biz.impl;

import cn.bdqn.biz.IUserBiz;
import cn.bdqn.dao.UserMapper;
import cn.bdqn.pojo.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserBiz implements IUserBiz {

    @Autowired
    private UserMapper  mapper;
    @Override
    public User login(User user) {
        return mapper.findUser(user);
    }
    @Override
    public  void modifyPassword(Integer id,String password){

        mapper.modifyUserPwd(id, password);
    }

    @Override
    public Page<User> findUserBypage(Integer pageNum, Integer pageSize,String queryname,Integer queryUserRole) {
      if (pageNum == null || " ".equals(pageNum)){
          pageNum=1;
      }
       if (pageSize==null){
           pageSize=5;
       }
    Page page= PageHelper.startPage(pageNum,pageSize);
       mapper.findUserByPage(queryname,queryUserRole);
        return page;
    }
}   
